﻿<ResourceDictionary
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
        
    <ControlTemplate x:Key="DialogEditWindowControlTemplate" TargetType="{x:Type Window}">

        <Border Style="{StaticResource FactoryWindowBorder}">
            <Grid>
                <Grid.RowDefinitions>
                    <RowDefinition Height="Auto"/>
                    <RowDefinition Height="*"/>
                </Grid.RowDefinitions>
                <Border x:Name="PART_TitleBar" Grid.Row="0" Style="{StaticResource FactoryWindowTitleBorder}" Background="{StaticResource WindowTitleBarBrush}">
                    <TextBlock Style="{StaticResource ApplicationTitleTextBlock}" Text="{TemplateBinding Title}"/>
                </Border>
                <Border Grid.Row="1" Style="{StaticResource FactoryWindowContentBorder}">
                    <Grid>
                        <Grid.RowDefinitions>
                            <RowDefinition Height="*"/>
                            <RowDefinition Height="Auto"/>
                        </Grid.RowDefinitions>

                        <ContentPresenter
                            Grid.Row="0"
                            Content="{TemplateBinding Content}"
                            ContentTemplate="{TemplateBinding ContentTemplate}" />

                        <Border Grid.Row="1" Style="{StaticResource FactoryWindowButtonBar}">
                            <StackPanel Orientation="Horizontal" HorizontalAlignment="Stretch" FlowDirection="RightToLeft">
                                <Button x:Name="applyButton" MinWidth="100"  Command="ApplicationCommands.Save">Ok</Button>
                                <Button x:Name="discardButton" MinWidth="100" Command="ApplicationCommands.Undo">Cancel</Button>
                            </StackPanel>
                        </Border>

                    </Grid>
                </Border>
            </Grid>


        </Border>
        
        <!--<ControlTemplate.Triggers>
            <MultiTrigger>
                <MultiTrigger.Conditions>
                    <Condition Property="ResizeMode" Value="CanResizeWithGrip"/>
                    <Condition Property="WindowState" Value="Normal"/>
                </MultiTrigger.Conditions>
                <Setter Property="Visibility" TargetName="WindowResizeGrip" Value="Visible"/>
            </MultiTrigger>
        </ControlTemplate.Triggers>-->
    </ControlTemplate>

    <ControlTemplate x:Key="DialogWindowControlTemplate" TargetType="{x:Type Window}">

        <Border Style="{StaticResource FactoryWindowBorder}">
            <Grid>
                <Grid.RowDefinitions>
                    <RowDefinition Height="Auto"/>
                    <RowDefinition Height="*"/>
                </Grid.RowDefinitions>
                <Border x:Name="PART_TitleBar" Grid.Row="0" Style="{StaticResource FactoryWindowTitleBorder}" Background="{StaticResource WindowTitleBarBrush}">
                    <TextBlock Style="{StaticResource ApplicationTitleTextBlock}" Text="{TemplateBinding Title}"/>
                </Border>
                <Border Grid.Row="1" Style="{StaticResource FactoryWindowContentBorder}">
                    <Grid>
                        <Grid.RowDefinitions>
                            <RowDefinition Height="*"/>
                            <RowDefinition Height="Auto"/>
                        </Grid.RowDefinitions>

                        <ContentPresenter
                            Grid.Row="0"
                            Content="{TemplateBinding Content}"
                            ContentTemplate="{TemplateBinding ContentTemplate}" />

                        <Border Grid.Row="1" Style="{StaticResource FactoryWindowButtonBar}">                            
                            <Button x:Name="PART_CloseButton" Width="100" HorizontalAlignment="Center" VerticalAlignment="Center">Ok</Button>                                                            
                        </Border>

                    </Grid>
                </Border>
            </Grid>


        </Border>

       
    </ControlTemplate>


    <ControlTemplate x:Key="NormalWindowControlTemplate" TargetType="{x:Type Window}">

        <Border Style="{StaticResource FactoryWindowBorder}" CornerRadius="5,5,0,0">
            <Grid>
                <Grid.RowDefinitions>
                    <RowDefinition Height="Auto"/>
                    <RowDefinition Height="*"/>
              
                </Grid.RowDefinitions>
                <Border x:Name="PART_TitleBar" Grid.Row="0" Style="{StaticResource FactoryWindowTitleBorder}" Background="{StaticResource WindowTitleBarBrush}">
                    <Grid>
                        <Grid.ColumnDefinitions>
                            <ColumnDefinition Width="*"/>
                            <ColumnDefinition Width="Auto"/>
                        </Grid.ColumnDefinitions>
                        <TextBlock
                            Grid.Column="0"
                            Style="{StaticResource ApplicationTitleTextBlock}" Text="{TemplateBinding Title}"/>
                        <StackPanel
                            Grid.Column="1"
                            Orientation="Horizontal">
                            <Image x:Name="PART_MinimizeButton" Source="/Images/WindowTitleBar/MinimizeButton.gif" Margin="0,0,3,0"/>
                            <Image x:Name="PART_CloseButton" Source="/Images/WindowTitleBar/CloseButton.gif"/>    
                        </StackPanel>
                        
                    </Grid>                    
                </Border>

             
                <Border Grid.Row="1" Style="{StaticResource FactoryWindowContentBorder}"  CornerRadius="0" >
                    <ContentPresenter                    
                        Content="{TemplateBinding Content}"
                        ContentTemplate="{TemplateBinding ContentTemplate}" />
                </Border>
              
            </Grid>
        </Border>


    </ControlTemplate>

    <Style x:Key="NormalWindow" TargetType="{x:Type Window}">
        <Setter Property="WindowStyle" Value="None"/>
        <Setter Property="Template" Value="{StaticResource NormalWindowControlTemplate}"/>        
    </Style>


    <Style x:Key="DialogEditWindow" TargetType="{x:Type Window}">
        <Setter Property="WindowStyle" Value="None"/>
        <Setter Property="Template" Value="{StaticResource DialogEditWindowControlTemplate}"/>
        <Setter Property="ResizeMode" Value="NoResize"/>
        <Setter Property="ShowInTaskbar" Value="False"/>        
    </Style>

    <Style x:Key="DialogWindow" TargetType="{x:Type Window}">
        <Setter Property="WindowStyle" Value="None"/>
        <Setter Property="Template" Value="{StaticResource DialogWindowControlTemplate}"/>
        <Setter Property="ResizeMode" Value="NoResize"/>
        <Setter Property="ShowInTaskbar" Value="False"/>
    </Style>

</ResourceDictionary>